//JavaScript Framework 2.0 Code
try {
	Type.registerNamespace('com.yonyou.ncmm_pac_pda.PoArriveScanController');
	com.yonyou.ncmm_pac_pda.PoArriveScanController = function() {
		com.yonyou.ncmm_pac_pda.PoArriveScanController.initializeBase(this);
		this.initialize();
	}

	function com$yonyou$ncmm_pac_pda$PoArriveScanController$initialize() {
		//you can programing by $ctx API
		//get the context data through $ctx.get()
		//set the context data through $ctx.push(json)
		//set the field of the context through $ctx.put(fieldName, fieldValue)
		//get the parameter of the context through $ctx.param(parameterName)
		//Demo Code:
		//    var str = $ctx.getString();      //获取当前Context对应的字符串
		//    alert($ctx.getString())          //alert当前Context对应的字符串
		//    var json = $ctx.getJSONObject(); //获取当前Context，返回值为json
		//    json["x"] = "a";        //为当前json增加字段
		//    json["y"] = [];           //为当前json增加数组
		//    $ctx.push(json);            //设置context，并自动调用数据绑定
		//    
		//    put方法需手动调用databind()
		//    var x = $ctx.get("x");    //获取x字段值
		//    $ctx.put("x", "b");     //设置x字段值
		//    $ctx.put("x", "b");     //设置x字段值
		//    $ctx.databind();            //调用数据绑定才能将修改的字段绑定到控件上
		//    var p1 = $param.getString("p1");   //获取参数p2的值，返回一个字符串
		//    var p2 = $param.getJSONObject("p2");   //获取参数p3的值，返回一个JSON对象
		//    var p3 = $param.getJSONArray("p3");   //获取参数p1的值，返回一个数组

		//your initialize code below...

	}

	function com$yonyou$ncmm_pac_pda$PoArriveScanController$evaljs(js) {
		eval(js)
	}

	function opendropmenu(sender, args) {
		PoArriveUtil.openDropDownListForScan("btn_menu");
	}

	function com$yonyou$ncmm_pac_pda$PoArriveScanController$onload(sender, args) {
		var row = $param.getJSONObject("row");
		// 如果不存在数据表则先创建
		NCMMPubUtil.createTable(PoArriveScanVO);
		if(!(row == null || row == "")) {
			var json = {};
			json = row;
			//$alert("获得的数据为"+$jsonToString(json));
			json = NCMMPubUtil.htmlspecialjson2UI(json);
			//$alert("转义后的数据为"+$jsonToString(json))
			$ctx.push(json);
			$ctx.dataBind();
		}
	}

	function com$yonyou$ncmm_pac_pda$PoArriveScanController$doscan(sender, args) {
		var listJson = $ctx.getJSONObject();
		//$alert(listJson);
		if(NCMMPubUtil.isEmpty(listJson.pk_order)) {
			$alert("请先指定单据！");
			return;
		}
		$scanner.open({
			bindfield: "marbarcode",
			callback: "marScanBack()"
		});
	}

	function marScanBack() {
		var marbarcode = $ctx.getString("marbarcode");
		if(marbarcode != null && marbarcode != "") {
			// 扫描的是物料码
			$id("textbox0").set("value", marbarcode);
			$ctx.dataBind();
		}
		parseMarCode(marbarcode);
		$id("textbox0").set("value", null);
	}

	function parseMarCode(marbarcode) {
		var listJson = $ctx.getJSONObject();
		if(NCMMPubUtil.isEmpty(listJson.pk_order)) {
			$alert("请先指定单据号！");
			return;
		}
		if(NCMMPubUtil.isEmpty(marbarcode)) {
			$alert("物料码为空！");
			return;
		}
		var marJson = NCMMBarcodeParseUtil.parseMaterialBar(marbarcode);
		var marID = marJson.pk_material;
		if(NCMMPubUtil.isEmpty(marID)) {
			$alert("解析物料码失败，请检查输入是否正确，或更新物料档案！");
			return;
		}
		if(!NCMMPubUtil.isEmpty(listJson.pk_order_b)) {
			var sql = " where pk_order_b = '" + listJson.pk_order_b + "'";
			NCMMPubUtil.queryVO(PoArriveVO, sql, function(data) {
				if(typeof(data) == 'undefined' || data == null || data.length == 0) {
					return;
				} else {
					//2 打开扫描记录编辑界面
					var vos = eval(data);
					vos = NCMMPubUtil.htmlspecialjsonarray2UI(vos);
					//$alert("扫描结果为=" + $jsonToString(vos));
					if(vos != null && vos.length > 0) {
						listJson = vos[0];
					}
				}
			});
		}
		if(NCMMPubUtil.isEmpty(listJson.pk_order_b) || marID != listJson.pk_material || marJson.vbatchcode != listJson["vbatchcode"]) {
			var sql = " where pk_order = '" + listJson.pk_order + "' and pk_material='" + marID + "'";
			var vo = queryScanInfo(sql, marJson.vbatchcode, listJson.pk_order_b);
			if(NCMMPubUtil.isEmpty(vo)) {
				$alert("扫描物料" + marJson.code + "不在对应的单据" + listJson["vbillcode"] + "中");
				return;
			}
			listJson = vo;
		}
		//if(!NCMMPubUtil.isEmpty(listJson["vbatchcode"]) && !NCMMPubUtil.isEmpty(marJson.vbatchcode) && listJson["vbatchcode"] != marJson.vbatchcode) {
		//	var isReplace = $confirm("扫描物料" + marJson.code + "的批次号和单据" + listJson["vbillcode"] + "的批次号不符，是否变更批次号?")
		//	if(isReplace == true || isReplace == "true") {
		//		listJson["vnotebody"] = "批次号由" + listJson["vbatchcode"] + "变更为" + marJson.vbatchcode;
		//	} else {
		//		return;
		//	}
		//}
		//listJson["vbarcode"] = "";
		if(NCMMPubUtil.isNotEmpty(marJson.vbatchcode)) {
			listJson["vbatchcode"] = marJson.vbatchcode;
			listJson["pk_batchcode"] = marJson.pk_batch;
		}
		listJson["vserialcode"] = marJson.vserialcode;
		var num = 1;
		var listnnum = parseFloat(listJson["nnum"]);
		var listnastnum = parseFloat(listJson["nastnum"]);
		var vchangerate = listJson["vchangerate"];
		var nastnum = PoArriveUtil.getAstnum(1, vchangerate);
		var unitBitNum = PoArriveUtil.getUnitBitnumber(listJson["cunitid"]);
		if(!NCMMPubUtil.isEmpty(unitBitNum)) {
			num = num.toFixed(unitBitNum);
			listnnum = listnnum.toFixed(unitBitNum);
		}
		var astunitBitNum = PoArriveUtil.getUnitBitnumber(listJson["castunitid"]);
		if(!NCMMPubUtil.isEmpty(astunitBitNum)) {
			nastnum = nastnum.toFixed(astunitBitNum);
			listnastnum = listnastnum.toFixed(astunitBitNum);
		}
		listJson["nscannum"] = num;
		listJson["nscanastnum"] = nastnum;
		listJson["pk_poarrivescan"] = getScanPK();
		listJson["nastnum"] = listnastnum;
		listJson["nnum"] = listnnum;

		NCMMPubUtil.insertVO(PoArriveScanVO, listJson);
		PoArriveUtil.updateScanedNum(listJson.pk_order_b);
		$ctx.push(listJson);
		$ctx.dataBind();

	}

	function getScanPK() {
		var date = new Date().getTime();
		var pk = "400630S" + date.toString();
		return pk;
	}

	function queryScanInfo(wheresql, vbatchcode, pk_order_b) {
		var vo = {};
		NCMMPubUtil.queryVO(PoArriveVO, wheresql, function(data) {
			if(typeof(data) == 'undefined' || data == null || data.length == 0) {
				vo = null;
			} else {
				//2 打开扫描记录编辑界面
				var vos = eval(data);
				vos = NCMMPubUtil.htmlspecialjson2UI(vos);
				//$alert("扫描结果为=" + $jsonToString(vos));
				if(vos != null && vos.length > 0) {
					if(vos.length == 1) {
						vo = vos[0];
					} else {
						vo = getScanVO(vos, vbatchcode, pk_order_b);
					}
				} else {
					vo = null;
				}
			}
		});
		return vo;
	}

	function getScanVO(vos, vbatchcode, pk_order_b) {
		//数量满足批次号为空的行，或当扫描物料的批次号为空时，数量不满足的行
		var result1 = [];
		//数量不满足批次号相同的行
		var result2 = [];
		//数量不满足批次号为空的行
		var result3 = [];
		//数量满足批次号不一致的行
		var result4 = [];
		//数量不满足批次不一致的行
		var result5 = [];
		var vo = {};
		for(var i = 0; i < vos.length; i++) {
			//数量满足
			if(vos[i].nnum > vos[i].nscanednum) {
				if(NCMMPubUtil.isEmpty(vbatchcode)) {
					return vos[i];
				} else if(vbatchcode == vos[i].vbatchcode) {
					return vos[i];
				} else if(NCMMPubUtil.isEmpty(vos[i].vbatchcode)) {
					result1.push(vos[i]);
				} else {
					result4.push(vos[i]);
				}
			}
			//数量不满足
			else {
				if(NCMMPubUtil.isEmpty(vbatchcode)) {
					result1.push(vos[i]);
				} else if(vbatchcode == vos[i].vbatchcode) {
					result2.push(vos[i]);
				} else if(NCMMPubUtil.isEmpty(vos[i].vbatchcode)) {
					result3.push(vos[i]);
				} else {
					result5.push(vos[i]);
				}
			}
		}
		if(result1.length > 0) {
			return result1[0];
		} else if(result2.length > 0) {
			return result2[0];
		} else if(result3.length > 0) {
			return result3[0];
		} else if(result4.length > 0) {
			return result4[0];
		} else if(result5.length > 0) {
			return result5[0];
		} else {
			return null;
		}
	}
	//提交
	function com$yonyou$ncmm_pac_pda$PoArriveScanController$doCommit(sender, args) {
		var stordoc = $cache.read("defaultstordoc");
		var json = $ctx.getJSONObject();
		//pk_recvstordoc
		//默认仓库和收货仓库均为空
		//if(NCMMPubUtil.isEmpty(stordoc) && NCMMPubUtil.isEmpty(json.pk_recvstordoc)) {
		//	$alert("默认仓库不能为空，请设置！");
		//	return;
		//}
		if(NCMMPubUtil.isEmpty(json.pk_order_b)) {
			$alert("无扫描数据，不能提交！");
			return;
		}
		if(json.nscannum == null || json.nscannum == 0 || json.nscannum == "0") {
			$alert("扫描主数量不能为空或0！")
			return;
		}
		if(json.nscanastnum == null || json.nscanastnum == 0 || json.nscanastnum == "0") {
			$alert("扫描数量不能为空或0！")
			return;
		}
		if(!$.isNumeric(json.nscannum) || !$.isNumeric(json.nscanastnum)) {
			$alert("数量输入不合法！")
			return;
		}
		$js.showLoadingBar();
		json = NCMMPubUtil.htmlspecialjson2UI(json);
		var isSuccess = doSave(json);
		if(isSuccess == false) {
			$js.hideLoadingBar();
			return;
		}
		//更新采购订单到货列表增加扫描数量 		
		var scanNum = PoArriveUtil.getScanVOCount(json.pk_order_b);
		if(scanNum > 1) {
			$js.hideLoadingBar();
			$alert("当前单据行有其他扫描记录，请全部选中后再提交！");
			return;
		}
		var sql = " where pk_poarrivescan='" + json.pk_poarrivescan + "'";
		var vo = {};
		NCMMPubUtil.queryVO(PoArriveScanVO, sql, function(scanData) {
			if(typeof(scanData) == 'undefined' || scanData == null || scanData.length == 0) {
				return;
			}
			var vos = eval(scanData);
			vos = NCMMPubUtil.htmlspecialjsonarray2UI(vos);
			vo = vos[0];
		});
		if(NCMMPubUtil.isEmpty(vo)) {
			$js.hideLoadingBar();
			$alert("当前扫描记录已经被删除，不能提交！")
			return;
		}
		var head = {};
		head["pk_order"] = vo.pk_order;
		head["ts_h"] = vo.hts;
		//		
		var item = {};
		//如果默认仓库不为空取默认仓库，否则取单据上的仓库
		if(NCMMPubUtil.isEmpty(stordoc) || NCMMPubUtil.isEmpty($stringToJSON(stordoc).pk_stordoc)) {
			item["pk_receivestore"] = vo.pk_recvstordoc;
		} else {
			item["pk_receivestore"] = $stringToJSON(stordoc).pk_stordoc;
		}
		item["pk_order_b"] = vo.pk_order_b;
		item["pk_material"] = vo.pk_material;
		item["castunitid"] = vo.castunitid;
		item["nscannum"] = vo.nscannum;
		item["nscanastnum"] = vo.nscanastnum;
		item["pk_batchcode"] = vo.pk_batchcode;
		item["vbatchcode"] = vo.vbatchcode;
		item["bc_vvendbatchcode"] = vo.bc_vvendbatchcode;
		var items = [{
			"item": item
		}];
		var billinfo = {
			"head": head,
			"items": items
		};
		var billinfos = [{
			"billinfo": billinfo
		}];
		//测试连接
		NCMMDBUtil.testNCConnection(function(data) {
			if(data == false || data == "false") {
				$js.hideLoadingBar();
				$toast("连接服务器失败，无法提交！");
				return;
			} else {
				//连接验证成功后的后续处理
				//$js.showLoadingBar();
				//$alert(billinfos);
				NCMMDBUtil.submitLocaldataToNC("21_23save", billinfos, function(commitInfo) {
					$js.hideLoadingBar();
					if(!NCMMPubUtil.isEmpty(commitInfo)) {
						if(commitInfo.return == null || commitInfo.return == "") {
							$alert("提交失败：" + $jsonToString(commitInfo));
						} else if(commitInfo["return"].returnFlag == 1) {
							$toast("提交成功！");
							var billbids = commitInfo.billbids;
							PoArriveUtil.deleteVOsAfterCommit(billbids);
							var list = {};
							$ctx.push(list);
							$ctx.dataBind();
						} else {
							$alert("提交失败" + $jsonToString(commitInfo.return.returnDesc));
						}
					} else {
						$alert("提交失败");
					}
				});
			}
		});
	}
	//扫描记录
	function com$yonyou$ncmm_pac_pda$PoArriveScanController$openScanList(sender, args) {
		$view.open({
			"viewid": "com.yonyou.ncmm_pac_pda.PoArriveScanList", //目标页面（首字母大写）全名
			"isKeep": "true", //打开新页面的同时是否保留当前页面，true为保留，false为不保留
		});
	}
	//暂存
	function com$yonyou$ncmm_pac_pda$PoArriveScanController$saveScanInfo(sender, args) {
		var json = $ctx.getJSONObject();
		var vchangerate = $ctx.getString("vchangerate");
		if(json.nscannum == null || json.nscannum == 0 || json.nscannum == "0") {
			$alert("扫描主数量不能为空或0！")
			return;
		}
		if(json.nscanastnum == null || json.nscanastnum == 0 || json.nscanastnum == "0") {
			$alert("扫描数量不能为空或0！")
			return;
		}
		if(!$.isNumeric(json.nscannum) || !$.isNumeric(json.nscanastnum)) {
			$alert("数量输入不合法！")
			return;
		}
		json = NCMMPubUtil.htmlspecialjson2UI(json);
		var isSuccess = doSave(json);
		if(isSuccess == true) {
			$toast("保存成功！");
		}
	}
	//保存按钮保存或提交前保存
	function doSave(json) {
		//如果批次号修改过
		if(NCMMPubUtil.isEmpty(json["vbatchcode"])) {
			json["pk_batchcode"] = "";
		} else {
			if(NCMMPubUtil.isTableExist(BatchcodeVO)) {
				var sql = " where vbatchcode='" + json["vbatchcode"] + "' and cmaterialvid='" + json["pk_material"] + "'";
				var pk_batchcode = "";
				NCMMPubUtil.queryVO(BatchcodeVO, sql, function(data) {
					if(typeof(data) == 'undefined' || data == null || data.length == 0) {
						return;
					} else {
						//2 打开扫描记录编辑界面
						var vos = eval(data);
						if(vos != null && vos.length > 0) {
							pk_batchcode = vos[0].pk_batchcode;
						}
					}
				});
			}
			json["pk_batchcode"] = pk_batchcode;
		}
		var numJson = PoArriveUtil.getScanedNum(json.pk_order_b);
		//如果主键不存在,保存
		if(NCMMPubUtil.isEmpty(json["pk_poarrivescan"])) {
			json["pk_poarrivescan"] = getScanPK();
			if(numJson["nscanednum"] + parseFloat(json.nscannum) - numJson["nnum"] > 0) {
				var isSave = $confirm("扫码数量超过应到货数量，请确认是否接收?");
				if(isSave != true && isSave != "true") {
					return false;
				}
			}
			NCMMPubUtil.insertVO(PoArriveScanVO, json);
		} else {		   
			var oldScanNum = getOldScanNum(json.pk_poarrivescan);
			numJson["nscanednum"] = numJson["nscanednum"] - oldScanNum;
			if(numJson["nscanednum"] + parseFloat(json.nscannum) - numJson["nnum"] > 0) {
				var isSave = $confirm("扫码数量超过应到货数量，请确认是否接收?");
				if(isSave != true && isSave != "true") {
					return false;
				}			
			}
			NCMMPubUtil.updateVO(PoArriveScanVO, json);
		}
		$ctx.push(json);
		$ctx.dataBind();
		//更新采购订单到货列表增加扫描数量 		
		PoArriveUtil.updateScanedNum(json.pk_order_b);
		return true;
	}

	function getBillBatchCode(pk_order_b) {
		var sql = " where pk_order_b='" + pk_order_b + "'";
		var batchcode = "";
		NCMMPubUtil.queryVO(PoArriveVO, sql, function(data) {
			if(typeof(data) == 'undefined' || data == null || data.length == 0) {
				return;
			} else {
				//2 打开扫描记录编辑界面
				var vos = eval(data);
				vos = NCMMPubUtil.htmlspecialjsonarray2UI(vos);
				if(vos != null && vos.length > 0) {
					batchcode = vos[0].vbatchcode;
				}
			}
		});
		return batchcode;
	}

	function getOldScanNum(pk_poarrivescan) {
		var sql = " where pk_poarrivescan='" + pk_poarrivescan + "'";
		var nscannum = 0;
		NCMMPubUtil.queryVO(PoArriveScanVO, sql, function(data) {
			//$alert(data);
			if(typeof(data) == 'undefined' || data == null || data.length == 0) {
				return;
			} else {
				//2 打开扫描记录编辑界面
				var vos = eval(data);
				vos = NCMMPubUtil.htmlspecialjsonarray2UI(vos);
				if(vos != null && vos.length > 0) {
					nscannum = parseFloat(vos[0].nscannum);
				}
			}
		});
		return nscannum;
	}

	function getAddScanedNum(scanedNum, currentScanedNum) {
		if(scanedNum == null || scanedNum == "") {
			scanedNum += "00.00000";
		} else {
			scanedNum = parseFloat(scanedNum);
		}
		if(currentScanedNum == null || currentScanedNum == "") {
			currentScanedNum += "1.00000";
		} else {
			currentScanedNum = parseFloat(currentScanedNum);
		}
		var newScanedNum = parseFloat(scanedNum).add(parseFloat(currentScanedNum));
		return newScanedNum;
	}

	function com$yonyou$ncmm_pac_pda$PoArriveScanController$close(sender, args) {
		$view.close();
	}

	function com$yonyou$ncmm_pac_pda$PoArriveScanController$calAstNum(sender, args) {
		var nn = args["newvalue"];
		if(NCMMPubUtil.isEmpty(nn)) {
			$ctx.put("nscanastnum", "");
			$ctx.dataBind();
			return;
		}
		if(nn == "-") {
			return;
		}
		if(!$.isNumeric(nn)) {
			$ctx.put("nscannum", args["oldvalue"]);
			$ctx.dataBind();
			return;
		}

		if(PoArriveUtil.isBsBitnumber(nn, $ctx.getString("cunitid"))) {
			$ctx.put("nscannum", args["oldvalue"]);
			$ctx.dataBind();
			return;
		}
		$ctx.dataCollect();
		var nnum = $ctx.getString("nscannum");
		if(NCMMPubUtil.isEmpty(nnum)) {
			$ctx.put("nscanastnum", "");
			$ctx.dataBind();
			return;
		}
		if(!$.isNumeric(nnum)) {
			$alert("扫描主数量输入不合法！");
			return;
		}
		var vchangerate = $ctx.getString("vchangerate");
		var nastnum = "";
		if(!NCMMPubUtil.isEmpty(nnum)) {
			nastnum = PoArriveUtil.getAstnum(nnum, vchangerate);
			var bitnum = PoArriveUtil.getUnitBitnumber($ctx.getString("castunitid"));
			if(!NCMMPubUtil.isEmpty(bitnum)) {
				nastnum = nastnum.toFixed(bitnum);
			}
			//$alert(nastnum);
			if(nastnum.toString() == "NaN") {
				$alert("数量输入不合法！");
				return;
			}
		}
		$ctx.put("nscanastnum", nastnum);
		$ctx.dataBind();
	}

	function com$yonyou$ncmm_pac_pda$PoArriveScanController$calNum(sender, args) {
		var nn = args["newvalue"];
		if(NCMMPubUtil.isEmpty(nn)) {
			$ctx.put("nscannum", "");
			$ctx.dataBind();
			return;
		}
		if(nn == "-") {
			return;
		}
		$ctx.dataCollect();
		if(!$.isNumeric(nn)) {
			$ctx.put("nscanastnum", args["oldvalue"]);
			$ctx.dataBind();
			return;
		}
		if(PoArriveUtil.isBsBitnumber(nn, $ctx.getString("castunitid"))) {
			$ctx.put("nscanastnum", args["oldvalue"]);
			$ctx.dataBind();
			return;
		}
		$ctx.dataCollect();
		var nastnum = $ctx.getString("nscanastnum");
		if(NCMMPubUtil.isEmpty(nastnum)) {
			$ctx.put("nscannum", "");
			$ctx.dataBind();
			return;
		}
		if(!$.isNumeric(nastnum)) {
			$alert("扫描数量输入不合法！");
			return;
		}
		var vchangerate = $ctx.getString("vchangerate");
		var nnum = "";
		if(!NCMMPubUtil.isEmpty(nastnum)) {
			nnum = PoArriveUtil.getNum(nastnum, vchangerate);
			var bitnum = PoArriveUtil.getUnitBitnumber($ctx.getString("cunitid"));
			if(!NCMMPubUtil.isEmpty(bitnum)) {
				nnum = nnum.toFixed(bitnum);
			}
			//$alert(nnum);
			if(nnum.toString() == "NaN") {
				$alert("数量输入不合法！");
				return;
			}
		}
		$ctx.put("nscannum", nnum);
		$ctx.dataBind();
	}
	//输入物料码
	function com$yonyou$ncmm_pac_pda$PoArriveScanController$inputMarCode(sender, args) {
		$ctx.dataCollect();
		var marbarcode = $ctx.getString("vbarcode");
		parseMarCode(marbarcode);
		$id("textbox0").set("value", null);
		$id("textbox0").focus();
	}
	// 打开参照页面
	function openRefPage(ncbillcode, ctxnamekey, ctxpkkey, pkfiel) {
		var jsonparam = {};
		getRefParam(ncbillcode, function(data) {
			jsonparam = data;
		});

		if(jsonparam == null) {
			//$alert("jsonparam is null!");
			return;
		}

		$view.open({
			viewid: "com.yonyou.ncmm_pac_pda.RefPage", //目标页面
			isKeep: "true", //打开新页面的同时是否保留当前页面，true为保留，false为不保留
			data: jsonparam,
			callback: function() {
				var refdata = $param.getJSONObject("data");
				$ctx.put(ctxnamekey, refdata["name"]);
				$ctx.put(ctxpkkey, refdata[pkfiel]);
				$ctx.dataBind();
				$cache.write("default" + ctxnamekey, $jsonToString(refdata));

				//设置了默认库存组织后，自动下载默认库存组织下的仓库
				//where pk_org='库存组织编码'
				if(ctxnamekey == "stockorg") {
					var condition = {
						"pk_org": "='" + refdata["code"] + "'"
					};
					processDocDataFromNC(StordocVO, condition);
				}
			}
		});
	}

	//获取参照vo的vo信息
	//reftype： 外系统调用标识
	function getRefParam(reftype, callback) {
		var condition = {
			"ncbillcode": reftype
		};
		NCMMPubUtil.queryVOByConditions(AppmappingheadVO, condition, function(data) {
			var jsondata = {
				bdlistdata: eval(data)
			};
			var reftitle = (jsondata.bdlistdata)[0]["appbillname"];
			if((jsondata.bdlistdata)[0]["downloadnum"] == "" || (jsondata.bdlistdata)[0]["downloadnum"] == "0") {
				$alert("【" + reftitle + "】没有可参照的数据");
				if(callback != null && callback != undefined && typeof(callback) == 'function') {
					callback(null);
				}
				return;
			}
			var reftablename = (jsondata.bdlistdata)[0]["apptablename"]; //本地表名
			var jsonparam = {
				reftype: reftype, //外系统调用标识
				reftitle: reftitle, //元数据显示名称
				reftablename: reftablename //本地表名
			};
			if(callback != null && callback != undefined && typeof(callback) == 'function') {
				callback(jsonparam);
			}
		});
	}
	com.yonyou.ncmm_pac_pda.PoArriveScanController.prototype = {
		inputMarCode: com$yonyou$ncmm_pac_pda$PoArriveScanController$inputMarCode,
		calNum: com$yonyou$ncmm_pac_pda$PoArriveScanController$calNum,
		calAstNum: com$yonyou$ncmm_pac_pda$PoArriveScanController$calAstNum,
		close: com$yonyou$ncmm_pac_pda$PoArriveScanController$close,
		saveScanInfo: com$yonyou$ncmm_pac_pda$PoArriveScanController$saveScanInfo,
		openScanList: com$yonyou$ncmm_pac_pda$PoArriveScanController$openScanList,
		doCommit: com$yonyou$ncmm_pac_pda$PoArriveScanController$doCommit,
		doscan: com$yonyou$ncmm_pac_pda$PoArriveScanController$doscan,
		onload: com$yonyou$ncmm_pac_pda$PoArriveScanController$onload,
		initialize: com$yonyou$ncmm_pac_pda$PoArriveScanController$initialize,
		evaljs: com$yonyou$ncmm_pac_pda$PoArriveScanController$evaljs
	};
	com.yonyou.ncmm_pac_pda.PoArriveScanController.registerClass('com.yonyou.ncmm_pac_pda.PoArriveScanController', UMP.UI.Mvc.Controller);
} catch(e) {
	$e(e);
}